package com.lagou.app;

import com.lagou.dao.EmployeeDao;
import org.junit.Test;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @Author wsl
 * @Date 2021/8/26 17:56
 * @Project_Name mysql
 */
public class TestEmployeeDao {

    //测试：根据name和gender进行数据查询，并将结果打印在控制台。
    @Test
    public void testFindEmployee() throws SQLException {

        //1.创建EmployeeDao对象
        EmployeeDao employeeDao = new EmployeeDao();

        //2.调用employee对象，返回一个结果集
        ResultSet resultSet = employeeDao.findEmployee("张三", "男");


        //3.处理结果集
        while (resultSet.next()){
            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            String gender = resultSet.getString("gender");
            double salary = resultSet.getDouble("salary");
            double bonus = resultSet.getDouble("bonus");
            Date join_date = resultSet.getDate("join_date");


            System.out.println(id+ " "+ name +" "+ gender +" "+ salary +" "+ bonus +" "+join_date);
        }


    }
}
